<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  <!-- </table>
    <tr>
       <th>名次</th>
       <th>姓名</th>
       <th>年纪</th>
       <th>性别</th>
       <th>销售额</th>
       <th>业绩状态</th>
       </tr>
     <tr>
       <td>1</td>
       <td>小明</td>
       <td>18</td>
       <td>男</td>
       <td>30w</td>
       <td>排名</td>
    </tr>
    <tr>
      <td>2</td>
      <td>小红</td>
      <td>26</td>
      <td>女</td>
      <td>99w</td>
      <td>排名</td>
   </tr>
   <tr>
    <td>3</td>
    <td>小刚</td>
    <td>19</td>
    <td>男</td>
    <td>88w</td>
    <td>排名</td>
 </tr>
 <tr>
  <td>4</td>
  <td>小丽</td>
  <td>20</td>
  <td>女</td>
  <td>67w</td>
  <td>排名</td>
</tr>
<tr>
  <td>5</td>
  <td>晓强</td>
  <td>23</td>
  <td>男</td>
  <td>77w</td>
  <td>排名</td>
</tr>
<tr>
  <td>6</td>
  <td>小张</td>
  <td>25</td>
  <td>女</td>
  <td>80w</td>
  <td>排名</td>
</tr>

       </table> -->
  <body>
    <script>
      let sales = [
        { name: '小明', age: 18, gender: '男', money: 30, status: 0 },
        { name: '小红', age: 26, gender: '女', money: 99, status: 3 },
        { name: '小刚', age: 19, gender: '男', money: 88, status: 2 },
        { name: '小丽', age: 20, gender: '女', money: 67, status: 1 },
        { name: '晓强', age: 23, gender: '女', money: 77, status: 1 },
        { name: '小张', age: 25, gender: '女', money: 80, status: 2 },
      ]
      // 分装函数
let arr=function(sales){
  // 模板
  let html=`<tr>
       <th>名次</th>
       <th>姓名</th>
       <th>年纪</th>
       <th>性别</th>
       <th>销售额</th>
       <th>业绩状态</th>
       </tr>`
      //  冒泡排序
      for(let i=0; i<sales.length -1;i++){  
       for(let j=0;j<sales.length -1 -i;j++){
       let temp=0
      if(sales[j].money < sales[j +1].money){
         temp = sales[j]
         sales[j]= sales[j +1]
        sales[j +1] =temp
        }
       }
      }

       for(let i=0;i<sales.length;i++){
     if(sales[i].status === 1){
      sales[i].status='及格'
     }else if(sales[i].status === 2){
      sales[i].status='良好'
     }else if(sales[i].status === 3){
      sales[i].status='优秀'
     }else{
      sales[i].status='不及格'
     }

     html +=`<br>`

     html +=`<tr>
       <td>${i +1}</td>
       <td>${sales[i]['name']}</td>
       <td>${sales[i]['age']}</td>
       <td>${sales[i]['gender']}</td>
       <td>${sales[i] ['money']}w</td>
       <td>${sales[i]['status']}</td>
    </tr>`
}
    html+=` </table>`
document.write(html);
}
// 调用函数
   arr(sales)

    </script>
  </body>
</html>